package com.neu.wangweili.servlet;

import com.neu.wangweili.service.W_StuService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet(name = "CheckStuByIdOrNoServlet", urlPatterns = {"/CheckStuByIdOrNoServlet"})
public class CheckStuByIdOrNoServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");

        String stu_no=request.getParameter("stu_no");
        String stu_name=request.getParameter("stu_name");
        W_StuService WStuService =new W_StuService();
        List<Map<String,Object>>list=null;
        list= WStuService.findByIdOrNo(stu_no,stu_name);
        if(list.size()>0){
            HttpSession session=request.getSession();
            session.setAttribute("item",list);
        request.getRequestDispatcher("WEB-INF/Mgr/checkstu.jsp").forward(request,response);
        }else{
            request.getRequestDispatcher("commons/fail.jsp").forward(request,response);
        }

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
